package org.jeecg.modules.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class GetDate {
    public static String getCurrentYearAndMonth(){// 获取当前年月
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        String currentYearAndMonth=sdf.format(calendar.getTime());
        return currentYearAndMonth;
    }

    public static String getLastYearAndMonth(){// 获取当前年的上个月
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
        String lastYearAndMonth=sdf.format(calendar.getTime());
        return lastYearAndMonth;
    }

    public static String getNextYearAndMonth(){// 获取当前年的下个月
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);
        String nextYearAndMonth=sdf.format(calendar.getTime());
        return nextYearAndMonth;
    }

    public static String getNextNextYearAndMonth(){// 获取当前年下个月的下个月
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 2);
        String nextNextYearAndMonth=sdf.format(calendar.getTime());
        return nextNextYearAndMonth;
    }

    public static String getCurrentDay(){// 获取当前日
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("dd");
        String currentDay=sdf.format(date);
        return currentDay;
    }

    public static String getCurrentDateAndTime(){// 获取当前年月日时分秒
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String current=sdf.format(date);
        return current;
    }
}
